

const MongoClient = require('mongodb').MongoClient;
const DB_CONN_STR = 'mongodb://lanyue_user:finfosoft123@121.42.253.149:19907/lanyue';

module.exports = function(dbname,callback){

        let selectData = function(db, callback) {
            //连接到表  
            let collection = db.collection(dbname);
            //查询数据
            let whereStr = {};
            collection.find(whereStr).toArray(function(err, result) {
                if(err)
                {
                    console.log('Error:'+ err);
                    return;
                }
                callback(result);
            });
        }

        MongoClient.connect(DB_CONN_STR, function(err, db) {
            console.log("查询连接成功！");
            selectData(db, function(result) {

                callback(result)
                db.close();

            });

        });
    }




